package com.example.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.example.pojo.fixtureChecklistPojo;
import com.example.pojo.oilChecklistPojo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * ClassName:oilChecklistMapp
 * Package:com.example.mapper
 * Description:
 *
 * @Author：牧星苑
 * @Create 2025/9/24 14:08
 * @Version 1.0
 */
@Mapper
public interface oilChecklistMapp {
    //一次插入多行点检结果
    @DS("newMscLowCodeFormal")
    void insertSeveralRows(@Param("pojoList") List<oilChecklistPojo> pojoList);

    //根据分页查询油液历史点检数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_oil_checklist where " +
            "workshop=#{workshop} and sys_deleted=0 " +
            "order by check_date DESC " +
            "limit #{startRow}, #{size}")
    List<oilChecklistPojo> queryByPage(Integer startRow, Integer size, String workshop);

    //查询所有油液历史点检数据条数
    @DS("newMscLowCodeFormal")
    @Select("SELECT COUNT(*) FROM ddm_oil_checklist where workshop=#{workshop} and sys_deleted=0")
    Integer queryQuantity(String workshop);

    //修改一行油液点检信息
    @DS("newMscLowCodeFormal")
    @Update("update ddm_oil_checklist " +
            "set " +
            "update_time=#{update_time}, " +
            "creator=#{creator}, " +
            "process_status=#{process_status}, " +
            "sys_update_user=#{sys_update_user}, "+
            "sys_audit_user=#{sys_audit_user}, " +
            "sys_audit_time=#{sys_audit_time}, " +
            "sys_deleted=#{sys_deleted}, " +
            "workshop=#{workshop}, " +
            "line=#{line}, " +
            "op=#{op}, " +
            "model=#{model}, "+
            "equipment_name_chinese=#{equipment_name_chinese}," +
            "equipment_name_english=#{equipment_name_english}, "+
            "equipment_name_russian=#{equipment_name_russian}, " +
            "oil_name_chinese=#{oil_name_chinese}, " +
            "oil_name_english=#{oil_name_english}, " +
            "oil_name_russian=#{oil_name_russian}, " +
            "specification=#{specification}, " +
            "refractive_index=#{refractive_index}," +
            "project=#{project}, " +
            "requirement=#{requirement}, "+
            "standard_value=#{standard_value}, " +
            "inspection_frequency=#{inspection_frequency}, " +
            "upper_limit=#{upper_limit}, " +
            "lower_limit=#{lower_limit}, " +
            "actual_value=#{actual_value}, " +
            "abnormal_description=#{abnormal_description}, " +
            "check_person=#{check_person}, " +
            "check_date=#{check_date}, " +
            "check_shift=#{check_shift}, " +
            "oil_basic_information_id=#{oil_basic_information_id} " +
            "where id=#{id}")
    void editOneById(oilChecklistPojo pojo);

    //根据点检项目查询指定数量的数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_oil_checklist " +
            "where sys_deleted=0 and " +
            "oil_basic_information_id=#{oil_basic_information_id} " +
            "order by check_date DESC " +
            "LIMIT #{quantity}")
    List<oilChecklistPojo> queryByOneField(Integer quantity, String oil_basic_information_id);

    // 根据动态条件分页查询油液历史点检数据
    @DS("newMscLowCodeFormal")
    List<oilChecklistPojo> queryByDynamicConditionsWithPagination(Map<String, Object> map);
    // 根据动态条件查询油液历史点检数据总条数
    @DS("newMscLowCodeFormal")
    Integer queryByDynamicConditionsCount(Map<String, Object> map);

    //查询所有油液历史点检数据
    @DS("newMscLowCodeFormal")
    @Select("select * from ddm_oil_checklist where sys_deleted=0")
    List<oilChecklistPojo> queryAll();
}
